﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DLL;

namespace NursingFormSystem.NursingPlanForm
{
    public partial class StopPlanForm : DevExpress.XtraEditors.XtraForm
    {

        string[] user;//当前的登录信息
        string[] patientinfo;
        string nursingevaluate = "";
        string id01 = "";


        //声明一个委托
        public delegate void SuccessUpdateDelegate();
        //声明事件
        public event SuccessUpdateDelegate ShowUpdate1;//
        public StopPlanForm(string[] user, string[] patientinfo, string nursingevaluate,string id)
        {
            InitializeComponent();
            dateEdit_sdate1.Text = DateTime.Now.Date.ToString("yyyy-MM-dd");
            timeEdit_stime.EditValue = DateTime.Now.ToShortTimeString().ToString();
            memoEdit1_s.Text = nursingevaluate;
            this.patientinfo = patientinfo;
            this.user = user;
            this.nursingevaluate = nursingevaluate;
            textEdit1_s.Text = user[1];
            id01 = id;
        }

        private void simpleButton_scancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void simpleButton_ssave_Click(object sender, EventArgs e)
        {
            SaveData();
        }

        //保存评价数据
        private void SaveData()
        {
            string sql = "";
            sql = "update NursingPlanRecord set NursingEvaluate='" + memoEdit1_s.Text + "',StopDate='" + dateEdit_sdate1.Text + "',StopTime='" + timeEdit_stime.Text + "',StopSign='" + user[1] + "' WHERE PatientId='" + patientinfo[0] + "' AND VisitId='" + patientinfo[1] + "'AND Id='" + id01 + "'";
            if (sql != "")//至少有一条数据
            {
                SqlHelper.ExecuteScalar(System.Data.CommandType.Text, sql, null);
            }
            MessageBox.Show("保存成功！");
            ShowUpdate1();
        }
    }
}